#pragma once

//#include "ModelIndex.h"
//#include "ModelViewDefines.h"

namespace DuiLib
{

	class CControlUI;
	class CAbstractItemModel;
	class CAbstractItemView;

	class UILIB_API CAbstractItemDelegate : public DuiLib::CDuiObject
	{
		friend class CAbstractItemView;

	public:
		sigslot::Signal<CAbstractItemModel*, const CModelIndex&> onSetModelData;

	public:
		CAbstractItemDelegate();
		virtual ~CAbstractItemDelegate();

		CAbstractItemModel* model() const;

		void showEditor(CControlUI* target, const CModelIndex& index);

	protected:
		virtual CControlUI* createEditor(CControlUI* target) = 0;
		virtual void destroyEditor(CControlUI* editor) = 0;

		virtual void setEditorData(CControlUI* editor, const CModelIndex& index) = 0;
		virtual void setModelData(CControlUI* editor, const CModelIndex& index) = 0;

	private Dui_Slots:
		void OnDelegateFinish(CControlUI* editor);

		void setModel(CAbstractItemModel* model);

	private:
		CControlUI* m_pDelegateCtrlItem;

		CModelIndex m_DelegateIndex;

		CAbstractItemModel* m_pModel;
	};

}